Skip to main content

How to find which process has occupied a specific port

netstat 1

sudo apt install net-tools
sudo netstat -ltnp

lsof 1

sudo apt install lsof
sudo lsof -i :80
  • DON'T forget the : before the port number

On Mac specifically: 2

lsof -nP -iTCP:$PORT | grep LISTEN

fuser 1

sudo apt install psmisc
# show a port number is listening by a process number
sudo fuser 3306/tcp
# check the process name by the process number
ps -p [processID] -o comm=

Usability Test

MethodLinuxMac
netstat
lsof
fuser

Footnotes

  1. Linux: Find Out Which Port Number a Process is Listening on – VITUX, Zotero 2 3

  2. Who is listening on a given TCP port on Mac OS X?, Zotero